package engine;

import static org.lwjgl.opengl.GL11.* ; 
import engine.graphics.Vertex2f;

public final class MADGL {
	
	public static void init(){ 
		switchToDefaultOrthoView(); 
		glEnable(GL_TEXTURE_2D); 
		glEnable(GL_BLEND); 
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//		enableLighting(); 
		glClearColor(1,1,1,1); 
	}
	
	public static void switchToDefaultOrthoView(){
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity(); 
		glOrtho(0, Engine.WIDTH, 0, Engine.HEIGHT, 1, -1);
		glMatrixMode(GL_MODELVIEW);
	}
	
	public static void switchToUpsideDownOrthoView(){
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity(); 
		glOrtho(0, Engine.WIDTH, Engine.HEIGHT, 0, 1, -1);
		glMatrixMode(GL_MODELVIEW);
	}
	
	public static void startMatrix(){
		glPushMatrix(); 
	}
	
	public static void endMatrix(){
		glPopMatrix(); 
	}
	
	public static void Translatef(Vertex2f vertex){
		glTranslatef(vertex.getX(), vertex.getY(), 0); 
	}
	
	public static void Translatef(float x, float y){
		glTranslatef(x, y, 0); 
	}
	
	public static void enableLighting(){
		glEnable(GL_LIGHTING); 
	}
	
	public static void disableLighting(){
		glDisable(GL_LIGHTING); 
	}
}
